extends Node2D

@export var health_component:HealthComponent
@export var sprite: Sprite2D
@export var stream_array : Array[AudioStream]

func _ready() -> void:
	if stream_array.size() > 0:
		$AudioStreamPlayer2D.stream = stream_array.pick_random()
	$GPUParticles2D.texture = sprite.texture
	$GPUParticles2D.scale = sprite.scale
	health_component.died.connect(on_died.bind())

func on_died() -> void:
	if owner == null: return
	global_position = owner.global_position
	reparent(Global.main.entities)
	$AnimationPlayer.play("death")
	$AudioStreamPlayer2D.play()
	
